﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OtechWebServer
{
    public partial class PrivateSetInfos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {             
            if (Request.QueryString["PhoneNumber"] != null &&
                Request.QueryString["IMEI"] != null)                
            {
                string phoneNumber = Request.QueryString["PhoneNumber"];
                string imei = Request.QueryString["IMEI"];

                string signature = Request.QueryString["Signature"];
                string taxiNo = Request.QueryString["TaxiNo"];
                string taxiType = Request.QueryString["TaxiType"];
                string driverName = Request.QueryString["DriverName"];
                string driverGender = Request.QueryString["DriverGender"];
                string nickName = Request.QueryString["NickName"];

                int count = 0;
                StringBuilder strSql = new StringBuilder();
                strSql.Append("UPDATE tprivate set ");
                if (!string.IsNullOrEmpty(signature))
                {
                    strSql.Append("Signature='");
                    strSql.Append(signature);
                    strSql.Append("',");
                    count++;
                }
                if (!string.IsNullOrEmpty(taxiNo))
                {
                    strSql.Append("TaxiNo='");
                    strSql.Append(taxiNo);
                    strSql.Append("',");
                    count++;
                }
                if (!string.IsNullOrEmpty(taxiType))
                {
                    strSql.Append("TaxiType='");
                    strSql.Append(taxiType);
                    strSql.Append("',");
                    count++;
                }
                if (!string.IsNullOrEmpty(driverName))
                {
                    strSql.Append("DriverName='");
                    strSql.Append(driverName);
                    strSql.Append("',");
                    count++;
                }
                if (!string.IsNullOrEmpty(driverGender))
                {
                    strSql.Append("DriverGender='");
                    strSql.Append(driverGender);
                    strSql.Append("',");
                    count++;
                }
                if (!string.IsNullOrEmpty(nickName))
                {
                    strSql.Append("NickName='");
                    strSql.Append(nickName);
                    strSql.Append("',");
                    count++;
                }
                if (count == 0)
                {
                    Response.Write("-2"); //未传入要修改的参数
                    return;
                }
                strSql.Remove(strSql.Length - 1, 1);//去掉最后的 ,
                strSql.Append(" WHERE PhoneNumber='");                                
                strSql.Append(phoneNumber);
                strSql.Append("' and IMEI='");
                strSql.Append(imei);
                strSql.Append("' ");
                int result = CommClass.MySqlHealper.ExecuteSql(strSql.ToString());
                Response.Write(result);//返回执行SQL影响行数的结果 0表示失败
            }
            else
            {
                Response.Write("-1"); // 未同时传入PhoneNumber、IMEI
            }
                
        }
    }
}